package com.ryan.encrypttool;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.ryan.encrypttool.entity.SshProperties;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;

import java.net.URL;
import java.util.ResourceBundle;

/**
 * @description:
 * @create: 2021-07-08 17:06
 * @author ryan
 * @version: 1.0
 */
public class HelloController implements Initializable {
  public TextField host;
  public TextField username;
  public TextField password;
  public TextArea contentView;
  public TextField execCommand;
  public Button mybutton;


  @Override
  public void initialize(URL url, ResourceBundle resourceBundle) {
    initialize();

    // 添加回车键的事件处理程序
    execCommand.setOnKeyPressed(event -> {
      if (event.getCode() == KeyCode.ENTER) {
        mybutton.fire();
      }
    });

  }

  private void initialize() {
    SshProperties sshProperties = new SshProperties();
    if (StrUtil.isNotEmpty(host.getText())) {
      sshProperties.setHost(host.getText());
    }

  }

  @FXML
  protected void onHelloButtonClick() {

    String s = IdUtil.randomUUID();
    System.out.println("s = " + s);
    contentView.setText(s);
  }

  public void resetClick(ActionEvent actionEvent) {

  }

}